#ifndef SINGLETON_H
#define SINGLETON_H
#include <iostream>
#include <atomic>
#include <mutex>


#if defined(__cplusplus) && __cplusplus >= 201103L
template<class T>
class Singleton
{
public:
    T *GetSingletonPtr()
    {
        if(_singleton == nullptr)
            _singleton = new (std::nothrow )T;

        return _singleton;
    }

    const T &GetSingleton()
    {
        if(_singleton == nullptr)
            _singleton = new (std::nothrow )T;

        return *_singleton;
    }

    void DeleteSingleton()
    {
        if( _singleton != nullptr)
        {
            delete _singleton;
            _singleton = nullptr;
        }
    }

private:
    static T *_singleton;
};

template<class T>
T *Singleton<T>::_singleton = nullptr;
#endif // SINGLETON_H
